
function HWEditor() {
	this.__arr = new Array();
}

HWEditor.prototype.add = function(id, htmContainer, xmlNode) {
	var obj = new Object();
	this.__arr[id] = obj;
	obj._htm = htmContainer;
	obj._xml = xmlNode;
	if (xmlNode["@attributes"].ed) {
		var othis = this;
		$(obj._htm).click(function(){
			othis.createInput(obj._htm, id);
		});
	}
}

HWEditor.prototype.remove = function(id) {
	this.__arr[id] = null;
}

HWEditor.prototype.length = function() {
	return this.__arr.length;
}

HWEditor.prototype.getHTML = function(id) {
	return this.__arr[id]._htm;
}

HWEditor.prototype.getXML = function(id) {
	return this.__arr[id]._xml;
}

HWEditor.prototype.updateValue = function(id, value) {
	this.updateXML(id, value);
	this.updateHTML(id);
}

HWEditor.prototype.updateXML = function(id, value) {
	var obj = this.__arr[id];
	if (obj == null)
		return;
	obj._xml["#text"] = value;
}

HWEditor.prototype.updateHTML = function(id) {
	var obj = this.__arr[id];
	if (obj == null)
		return;
	updateHTMLCell(obj._htm);
//	htmCell.innerText = htmCell.getAttribute("___xml").text;
}

HWEditor.prototype.createInput = function(oHTML, id) {
	var oInput = document.createElement("input");
	$(oInput).css("width", "90%");
	var sValue = $(oHTML).text();
	$(oHTML).empty();
	oInput.value = sValue;
	$(oHTML).append(oInput);
	oInput.focus();
	var othis = this;
	$(oInput).bind("blur", function(){
		var sNewValue = this.value;
		othis.updateXML(id, sNewValue);
		othis.updateHTML(id);
		$(this).remove();
	});
}

